package com.shp.controller;

import com.shp.pojo.Recharge;
import com.shp.service.PurseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Description:
 *  支付控制器
 * @author zwl
 * @version 1.0
 * @date 2020/5/1 21:32
 */
@Controller
@RequestMapping(value = "/alipay")
public class AliPayController {

    @Autowired
    private PurseService purseService;

    /**
     * 分段提交
     * @param orderId 订单编号
     * @return goPay.jsp
     */
    @RequestMapping(value = "/gopay",method = RequestMethod.GET)
    public String goPay(@RequestParam(value = "orderId") String orderId){
        Recharge recharge = purseService.getRecharge(orderId);
        if(recharge != null){
            
        }else{

        }
        return "alipay/goPay";
    }

    /**
     * 前往支付宝第三方网关进行支付
     * @param orderId 订单编号
     * @param request HttpServletRequest
     * @param response HttpServletResponse
     * @return 支付宝的支付页面
     */
    @RequestMapping(value = "/goalipay",produces = "text/html;charset=UTF-8",method = RequestMethod.GET)
    @ResponseBody
    public String goAliPay(String orderId, HttpServletRequest request, HttpServletResponse response){
        return null;
    }

    /**
     * 支付宝同步通知页面
     * @param request HttpServletRequest
     * @param response HttpServletResponse
     * @return alipaySuccess.jsp
     */
    @RequestMapping(value = "/alipayReturnNotice")
    public String aliPayReturnNotice(HttpServletRequest request,HttpServletResponse response){
        return "alipay/alipaySuccess";
    }


    /**
     * 支付宝异步通知页面
     * @param request HttpServletRequest
     * @param response HttpServletResponse
     * @return success
     */
    @RequestMapping(value = "/alipayNotifyNotice")
    public String aliPayNotifyNotice(HttpServletRequest request,HttpServletResponse response){
        return "success";
    }
}
